﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IniHelper;
using System.Reflection;
namespace GlobalConfigFactory
{
    public static class GlobalConfigStarter
    {
        public static void startWindow()
        {
            Dictionary<string, List<string>> searchFields = new Dictionary<string,List<string>>();
            List<string> keys = null;

            string dllPath = Assembly.GetExecutingAssembly().Location;
            dllPath = dllPath.Substring(0, dllPath.LastIndexOf('\\'));
            IniContainer container = IniContainer.createContainer("config", dllPath);
            keys = new List<string>();
            keys.Add("WebConfig");
            searchFields.Add("WebFile", keys);
            container.load(searchFields);

            string webPath = container.getValues("WebFile", "WebConfig").ElementAt(0);
            webPath = webPath.Substring(0, webPath.LastIndexOf('\\'));
            IniContainer webInfoContainer = IniContainer.createContainer("web", webPath);
            searchFields.Clear();
            keys = new List<string>();
            keys.Add("TK"); keys.Add("ProInfo"); keys.Add("path(s)"); keys.Add("FrmInfo");
            searchFields.Add("WebFile", keys);
            webInfoContainer.load(searchFields);

            GlobalConfigWindow windowReference = new GlobalConfigWindow(webInfoContainer);
            windowReference.ShowDialog();
        }
    }
}
